*****************************************************************************************
**Replication files for all tables and creation of figure datasets in
**Selecting for Masculinity: Women's Under-Representation in the Republican Party
**Christopher F. Karpowitz, J. Quin Monson, Jessica Robinson Preece, Alejandra Aldridge
**American Political Science Review
*****************************************************************************************


**Change working directory to current location of data
cd "~/APSR Replication Files"


**Be sure the folder includes sub-folders for Tables and Figures

********************************************************************************
**Analysis of Study 1 and Study 2, 2016-18 CCES 
********************************************************************************

use "CCES2016-18 Merged_replication.dta", clear


**Create tables for appendix
**Double bind 
**Table A1: Effects of Experimental Conditions on Candidate Trait Evaluations, 2016-18 CCES 

**Democrats
reg diff_like i.profile2 i.year if primary==2
outreg2 using Tables/Table_A1, replace dec(3)  
reg diff_like i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==2
outreg2 using Tables/Table_A1, append dec(3)  

reg diff_comp i.profile2 i.year if primary==2
outreg2 using Tables/Table_A1, append dec(3)  
reg diff_comp i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==2
outreg2 using Tables/Table_A1, append dec(3)  

**Republicans
reg diff_like i.profile2 i.year if primary==1
outreg2 using Tables/Table_A1, append dec(3)  
reg diff_like i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==1
outreg2 using Tables/Table_A1, append dec(3)  

reg diff_comp i.profile2 i.year if primary==1
outreg2 using Tables/Table_A1, append dec(3)  
reg diff_comp i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==1
outreg2 using Tables/Table_A1, append tex dec(3)  


**Table A2: Relationship between Candidate Profile and Women's Electoral Success, 2016-18 CCES
probit vote_julie i.profile2 i.year if primary==1
outreg2 using Tables/Table_A2, replace dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit vote_julie i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==1
outreg2 using Tables/Table_A2, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))

probit vote_julie i.profile2 i.year if primary==2
outreg2 using Tables/Table_A2, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))
probit vote_julie i.profile2 female age religiosity married faminc_use nonwhite educ i.year if primary==2
outreg2 using Tables/Table_A2, append tex dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))


**Table A3: Relationship between Candidate Profile and Women's Electoral Success by Respondent Ideology, 2016-18 CCES
probit vote_julie i.profile2##i.very_con i.year if primary==1
outreg2 using Tables/Table_A3, replace dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))
probit vote_julie i.profile2##i.very_con female age religiosity married faminc_use nonwhite educ i.year if primary==1
outreg2 using Tables/Table_A3, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))

probit vote_julie i.profile2##i.very_lib i.year if primary==2
outreg2 using Tables/Table_A3, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))
probit vote_julie i.profile2##i.very_lib female age religiosity married faminc_use nonwhite educ i.year if primary==2
outreg2 using Tables/Table_A3, append tex dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))



**Tables A10 and A11: Summary stats for 2016 and 2018 CCES

sutex2 female age religiosity married faminc_use nonwhite educ pid7 if year==2016, varlabels saving(Tables/Table_A10) replace 
sutex2 female age religiosity married faminc_use nonwhite educ pid7 if year==2018, varlabels saving(Tables/Table_A11) replace 

**Estimation of effect sizes
esize twosample diff_like if primary==1 & (profile==1|profile==3), by(profile)
esize twosample diff_comp if primary==1 & (profile==1|profile==3), by(profile)



**Create datasets for figures in R
**Figure 1
use "CCES2016-18 Merged_replication.dta", clear


reg diff_like i.profile2 i.year if primary==1
margins i.profile2, saving(Figures/cces_db_like_gop, replace)

reg diff_comp i.profile2 i.year if primary==1
margins i.profile2, saving(Figures/cces_db_comp_gop, replace)


reg diff_like i.profile2 i.year if primary==2
margins i.profile2, saving(Figures/cces_db_like_dem, replace)

reg diff_comp i.profile2 i.year if primary==2
margins i.profile2, saving(Figures/cces_db_comp_dem, replace)


use "Figures/cces_db_like_gop.dta", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Likeability"

save "Figures/cces_db_like_gop", replace

use "Figures/cces_db_comp_gop", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Competence"

save "Figures/cces_db_comp_gop.dta", replace

append using "Figures/cces_db_like_gop.dta"

gen primary="gop"

save "Figures/cces_db_gop.dta", replace


use "Figures/cces_db_like_dem.dta", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Likeability"

save "Figures/cces_db_like_dem", replace

use "Figures/cces_db_comp_dem", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Competence"

save "Figures/cces_db_comp_dem.dta", replace

append using "Figures/cces_db_like_dem.dta"

gen primary="dem"

save "Figures/cces_db_dem.dta", replace

append using "Figures/cces_db_gop.dta"

save "Figures/cces_db.dta", replace


**Vote estimates
**Figure 2
use "CCES2016-18 Merged_replication.dta", clear

reg vote_julie i.profile2 i.year if primary==1
margins i.profile2, saving(Figures/cces_vote_gop, replace)

reg vote_julie i.profile2 i.year if primary==2
margins i.profile2, saving(Figures/cces_vote_dem, replace)


use "Figures/cces_vote_gop.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

gen primary="Republican"

save "Figures/cces_vote_gop.dta", replace


use "Figures/cces_vote_dem.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

gen primary="Democrat"

save "Figures/cces_vote_dem.dta", replace

append using "Figures/cces_vote_gop.dta"

save "Figures/cces_vote_byparty.dta", replace



use "CCES2016-18 Merged_replication.dta", clear


reg vote_julie i.profile2##i.very_con i.year if primary==1
margins i.profile2#i.very_con, saving(Figures/cces_vote_byideo_gop, replace)

reg vote_julie i.profile2##i.very_lib i.year if primary==2
margins i.profile2#i.very_lib, saving(Figures/cces_vote_byideo_dem, replace)


use "Figures/cces_vote_byideo_gop.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _m2 ideo 
rename _statistic statistic

gen primary="Republican"

save "Figures/cces_vote_byideo_gop.dta", replace


use "Figures/cces_vote_byideo_dem.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _m2 ideo 
rename _statistic statistic

gen primary="Democrat"

save "Figures/cces_vote_byideo_dem.dta", replace

append using "Figures/cces_vote_byideo_gop.dta"
replace ideo=2 if primary=="Republican" & ideo==1
label def ideo 0 "Other" 1 "Strong Liberal" 2 "Strong Conservative"
label val ideo ideo 

save "Figures/cces_vote_byideo.dta", replace



********************************************************************************
***Analysis of Study 3: 2016 Caucus Attender Survey
********************************************************************************


use "2016_Caucus_Survey_replication.dta", clear

**These analyses are restricted to respondents who did not receive the gender equality prime

**Table A4: Effects of Experimental Conditions on Candidate Trait Evaluations, 2016 Caucus Attender Study
reg diff_like i.profile i.gender_appeal if treat==0
outreg2 using Tables/Table_A4, replace dec(3)  
reg diff_like i.profile i.gender_appeal female age relig married income nonwhite educ if treat==0
outreg2 using Tables/Table_A4,  append dec(3)  
reg diff_comp i.profile i.gender_appeal if treat==0
outreg2 using Tables/Table_A4,  append dec(3)  
reg diff_comp i.profile i.gender_appeal female age relig married income nonwhite educ if treat==0
outreg2 using Tables/Table_A4,  append tex dec(3)  


esize twosample diff_like if (profile==1|profile==3), by(profile)
esize twosample diff_comp if (profile==1|profile==3), by(profile)

esize twosample diff_like if (profile==1|profile==4), by(profile)
esize twosample diff_comp if (profile==1|profile==4), by(profile)

esize twosample diff_like if (profile==1|profile==5), by(profile)
esize twosample diff_comp if (profile==1|profile==5), by(profile)


**Table A5: Relationship between Candidate Profile and Women's Electoral Success, 2016 Caucus Attender Study
probit vote_julie i.profile i.gender_appeal if treat==0
outreg2 using Tables/Table_A5, replace dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))

probit vote_julie i.profile i.gender_appeal female age relig married income nonwhite educ if treat==0
outreg2 using Tables/Table_A5, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))


probit vote_julie i.profile##i.female i.gender_appeal if treat==0 
outreg2 using Tables/Table_A5, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))
probit vote_julie i.profile##i.female i.gender_appeal age relig married income nonwhite educ if treat==0
outreg2 using Tables/Table_A5, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))

probit vote_julie i.profile##i.strong_con i.gender_appeal if treat==0
outreg2 using Tables/Table_A5, append dec(3)  addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))
probit vote_julie i.profile##i.strong_con i.gender_appeal female age relig married income nonwhite educ if treat==0
outreg2 using Tables/Table_A5, append tex dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p))




**Table A12: Summary Stats for 2016 Caucus Attender Survey/Unmatched
sutex2 female age relig married income nonwhite educ if treat==0, varlabels saving(Tables/Table_A12) replace 


**Create files for producing figures
**Double Bind Results
use "2016_Caucus_Survey_replication.dta", clear

reg diff_like i.profile i.gender_appeal if treat==0
margins i.profile, saving(Figures/caucus_db_like, replace)

reg diff_comp i.profile i.gender_appeal if treat==0
margins i.profile, saving(Figures/caucus_db_comp, replace)

use "Figures/caucus_db_like.dta", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Likeability"

save "Figures/caucus_db_like.dta", replace

use "Figures/caucus_db_comp.dta", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Competence"

save "Figures/caucus_db_comp.dta", replace

append using "Figures/caucus_db_like.dta"

save "Figures/caucus_2016_db.dta", replace


use "2016_Caucus_Survey_replication.dta", clear

probit vote_julie i.profile i.gender_appeal if treat==0
margins i.profile, saving(Figures/vote_basic, replace)

probit vote_julie i.profile##i.female i.gender_appeal if treat==0 
margins i.profile#i.female, saving(Figures/vote_gender, replace)

probit vote_julie i.profile##i.strong_con i.gender_appeal if treat==0
margins i.profile#i.strong_con, saving(Figures/vote_ideo, replace)

probit vote_julie i.profile##i.female i.gender_appeal if treat==0 & strong_con==1
margins i.profile#i.female, saving(Figures/vote_gender_strongcon, replace)



use "Figures/vote_basic.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

save "Figures/caucus_2016_vote_basic.dta", replace


use "Figures/vote_gender.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _m2 female
rename _statistic statistic

label def female 0 "Male" 1 "Female"
label val female female

save "Figures/caucus_2016_vote_gender.dta", replace

use "Figures/vote_gender_strongcon.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _m2 female
rename _statistic statistic

label def female 0 "Male" 1 "Female"
label val female female

save "Figures/caucus_2016_vote_gender_strongcon.dta", replace




use "Figures/vote_ideo.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _m2 ideo
rename _statistic statistic

label def ideo 0 "Other " 1 "Strong Conservative"
label val ideo ideo

save "Figures/caucus_2016_vote_ideo.dta", replace




********************************************************************************
***Analysis of Study 4: 2018 Caucus Attender Survey
********************************************************************************

use "2018_Caucus_Survey_replication.dta", clear


**Table A13: Summary Statistics, Study 4, 2018 Caucus Attender Study
sutex2 female age relig married income nonwhite educ, varlabels saving(Tables/Table_A13) replace 

**Table A7: Effects of Experimental Conditions on Candidate Trait Evaluations 2018 Caucus Attender Study
reg diff_like i.treat
outreg2 using Tables/Table_A7, replace dec(3)  
reg diff_like i.treat female age relig married income nonwhite educ
outreg2 using Tables/Table_A7, append dec(3)  
reg diff_comp i.treat
outreg2 using Tables/Table_A7, append dec(3)  
reg diff_comp i.treat female age relig married income nonwhite educ
outreg2 using Tables/Table_A7, append tex dec(3)  


**Table A8: Relationship between Candidate Profile and Women's Electoral Success, 2018 Caucus Attenders
**All Republicans
probit vote_julie i.treat
outreg2 using Tables/Table_A8, replace dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit vote_julie i.treat female age relig married income nonwhite educ
outreg2 using Tables/Table_A8, append dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 

*Strong Conservatives only
probit vote_julie i.treat if strong_con==1
outreg2 using Tables/Table_A8, append dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit vote_julie i.treat female age relig married income nonwhite educ if strong_con==1
outreg2 using Tables/Table_A8, append tex dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 



**Create datasets for figures in R
use "2018_Caucus_Survey_replication.dta", clear

*Double bind
reg diff_like i.treat
margins i.treat, saving(Figures/caucus_2018_db_like, replace)
reg diff_comp i.treat
margins i.treat, saving(Figures/caucus_2018_db_comp, replace)

*Vote
probit vote_julie i.treat
margins i.treat, saving(Figures/caucus_2018_vote, replace)

probit vote_julie i.treat if strong_con==1
margins i.treat, saving(Figures/caucus_2018_vote_strongcon, replace)

probit vote_julie i.treat if strong_con==0
margins i.treat, saving(Figures/caucus_2018_vote_othercon, replace)



use "Figures/caucus_2018_db_like.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Likeability"

gen profile="Masc" if treat==1|treat==5|treat==9|treat==13
replace profile="Masc+" if treat==2|treat==6|treat==10|treat==14
replace profile="Fem" if treat==3|treat==7|treat==11|treat==15
replace profile="Fem+" if treat==4|treat==8|treat==12|treat==16

gen male="Masculine" if treat>=1&treat<=4
replace male="Masculine Parent" if treat>=5&treat<=8
replace male="Feminine" if treat>=9 & treat<=12
replace male="Feminine Parent" if treat>=13&treat<=16

gen male_facet=1 if treat>=1&treat<=8
replace male_facet=2 if treat>=9&treat<=16

save "Figures/caucus_2018_db_like.dta", replace

use "Figures/caucus_2018_db_comp.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin diff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic
gen trait="Competence"

gen profile="Masc" if treat==1|treat==5|treat==9|treat==13
replace profile="Masc+" if treat==2|treat==6|treat==10|treat==14
replace profile="Fem" if treat==3|treat==7|treat==11|treat==15
replace profile="Fem+" if treat==4|treat==8|treat==12|treat==16

gen male="Masculine" if treat>=1&treat<=4
replace male="Masculine Parent" if treat>=5&treat<=8
replace male="Feminine" if treat>=9 & treat<=12
replace male="Feminine Parent" if treat>=13&treat<=16

gen male_facet=1 if treat>=1&treat<=8
replace male_facet=2 if treat>=9&treat<=16

save "Figures/caucus_2018_db_comp.dta", replace

append using "Figures/caucus_2018_db_like.dta"
drop if male=="Masculine Parent"|male=="Feminine Parent"


save "Figures/caucus_2018_db.dta", replace

use "Figures/caucus_2018_db_comp.dta", clear 
append using "Figures/caucus_2018_db_like.dta"
keep if male=="Masculine Parent"|male=="Feminine Parent"
save "Figures/caucus_2018_db_2.dta", replace



use "Figures/caucus_2018_vote.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

gen profile="Masc" if treat==1|treat==5|treat==9|treat==13
replace profile="Masc+" if treat==2|treat==6|treat==10|treat==14
replace profile="Fem" if treat==3|treat==7|treat==11|treat==15
replace profile="Fem+" if treat==4|treat==8|treat==12|treat==16

gen male="Masculine" if treat>=1&treat<=4
replace male="Masculine Parent" if treat>=5&treat<=8
replace male="Feminine" if treat>=9 & treat<=12
replace male="Feminine Parent" if treat>=13&treat<=16

gen fem_treat=.
replace fem_treat=1 if profile=="Masc"
replace fem_treat=2 if profile=="Masc+"
replace fem_treat=3 if profile=="Fem+"
replace fem_treat=4 if profile=="Fem"

label def fem_treat 1 "Masculine" 2 "Masculine Mom" 3 "Feminine Mom" 4 "Feminine"
label val fem_treat fem_treat

gen male_treat=.
replace male_treat=1 if male=="Masculine"
replace male_treat=2 if male=="Masculine Parent"
replace male_treat=3 if male=="Feminine Parent"
replace male_treat=4 if male=="Feminine"

label def male_treat 1 "Masculine" 2 "Masculine Dad" 3 "Feminine Dad" 4 "Feminine"
label val male_treat male_treat 




gen male_facet=1 if treat>=1&treat<=8
replace male_facet=2 if treat>=9&treat<=16

gen base_temp=vote_julie if treat==1
egen base=mean(base_temp)
drop base_temp

gen base_se_temp=se if treat==1
egen base_se=mean(base_se_temp)
drop base_se_temp

gen diff_label=vote_julie-base

save "Figures/caucus_2018_vote.dta", replace


gen vote_male=1-vote_julie

gen female_facet=1 if treat==1|treat==2|treat==5|treat==6|treat==9|treat==10|treat==13|treat==14
replace female_facet=2 if female_facet~=1

drop if male_facet~=1 & female_facet~=1
drop statistic ci_lb ci_ub base base_se
drop if treat==6|treat==7|treat==8|treat==10|treat==14
drop diff_label

reshape long vote_, i(vote_julie vote_male) j(candidate) string
replace candidate="woman" if candidate=="julie"
replace candidate="man" if candidate=="male"
drop vote_julie vote_male

replace profile="Feminine Parent" if profile=="Fem+"
replace profile="Feminine" if profile=="Fem"
replace profile="Masculine" if profile=="Masc"
replace profile="Masculine Parent" if profile=="Masc+"

ren profile female

gen condition=""
replace condition=female if candidate=="woman"
replace condition=male if candidate=="man"

drop if candidate=="man" & male=="Masculine" & female~="Masculine"
drop if candidate=="woman" & female=="Masculine" & male~="Masculine"

save "Figures/caucus_2018_vote_reshape.dta", replace


use "Figures/caucus_2018_vote_strongcon.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

gen profile="Masc" if treat==1|treat==5|treat==9|treat==13
replace profile="Masc+" if treat==2|treat==6|treat==10|treat==14
replace profile="Fem" if treat==3|treat==7|treat==11|treat==15
replace profile="Fem+" if treat==4|treat==8|treat==12|treat==16

gen male="Masculine" if treat>=1&treat<=4
replace male="Masculine Parent" if treat>=5&treat<=8
replace male="Feminine" if treat>=9 & treat<=12
replace male="Feminine Parent" if treat>=13&treat<=16

gen male_facet=1 if treat>=1&treat<=8
replace male_facet=2 if treat>=9&treat<=16

gen base_temp=vote_julie if treat==1
egen base=mean(base_temp)
drop base_temp

gen base_se_temp=se if treat==1
egen base_se=mean(base_se_temp)
drop base_se_temp

gen diff_label=vote_julie-base

gen fem_treat=.
replace fem_treat=1 if profile=="Masc"
replace fem_treat=2 if profile=="Masc+"
replace fem_treat=3 if profile=="Fem+"
replace fem_treat=4 if profile=="Fem"

label def fem_treat 1 "Masculine" 2 "Masculine Mom" 3 "Feminine Mom" 4 "Feminine"
label val fem_treat fem_treat

gen male_treat=.
replace male_treat=1 if male=="Masculine"
replace male_treat=2 if male=="Masculine Parent"
replace male_treat=3 if male=="Feminine Parent"
replace male_treat=4 if male=="Feminine"

label def male_treat 1 "Masculine" 2 "Masculine Dad" 3 "Feminine Dad" 4 "Feminine"
label val male_treat male_treat 


save "Figures/caucus_2018_vote_strongcon.dta", replace

gen vote_male=1-vote_julie

gen female_facet=1 if treat==1|treat==2|treat==5|treat==6|treat==9|treat==10|treat==13|treat==14
replace female_facet=2 if female_facet~=1

drop if male_facet~=1 & female_facet~=1
drop statistic ci_lb ci_ub base base_se
drop if treat==6|treat==7|treat==8|treat==10|treat==14
drop diff_label

reshape long vote_, i(vote_julie vote_male) j(candidate) string
replace candidate="woman" if candidate=="julie"
replace candidate="man" if candidate=="male"
drop vote_julie vote_male

replace profile="Feminine Parent" if profile=="Fem+"
replace profile="Feminine" if profile=="Fem"
replace profile="Masculine" if profile=="Masc"
replace profile="Masculine Parent" if profile=="Masc+"

ren profile female

gen condition=""
replace condition=female if candidate=="woman"
replace condition=male if candidate=="man"

drop if candidate=="man" & male=="Masculine" & female~="Masculine"
drop if candidate=="woman" & female=="Masculine" & male~="Masculine"

save "Figures/caucus_2018_vote_strongcon_reshape.dta", replace


use "Figures/caucus_2018_vote_othercon.dta", clear

drop _deriv _term _predict _at _atopt _pvalue
rename _margin vote_julie
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
rename _m1 treat
rename _statistic statistic

gen profile="Masc" if treat==1|treat==5|treat==9|treat==13
replace profile="Masc+" if treat==2|treat==6|treat==10|treat==14
replace profile="Fem" if treat==3|treat==7|treat==11|treat==15
replace profile="Fem+" if treat==4|treat==8|treat==12|treat==16

gen male="Masculine" if treat>=1&treat<=4
replace male="Masculine Parent" if treat>=5&treat<=8
replace male="Feminine" if treat>=9 & treat<=12
replace male="Feminine Parent" if treat>=13&treat<=16

gen male_facet=1 if treat>=1&treat<=8
replace male_facet=2 if treat>=9&treat<=16

gen base_temp=vote_julie if treat==1
egen base=mean(base_temp)
drop base_temp

gen base_se_temp=se if treat==1
egen base_se=mean(base_se_temp)
drop base_se_temp

gen diff_label=vote_julie-base

gen fem_treat=.
replace fem_treat=1 if profile=="Masc"
replace fem_treat=2 if profile=="Masc+"
replace fem_treat=3 if profile=="Fem+"
replace fem_treat=4 if profile=="Fem"

label def fem_treat 1 "Masculine" 2 "Masculine Mom" 3 "Feminine Mom" 4 "Feminine"
label val fem_treat fem_treat

gen male_treat=.
replace male_treat=1 if male=="Masculine"
replace male_treat=2 if male=="Masculine Parent"
replace male_treat=3 if male=="Feminine Parent"
replace male_treat=4 if male=="Feminine"

label def male_treat 1 "Masculine" 2 "Masculine Dad" 3 "Feminine Dad" 4 "Feminine"
label val male_treat male_treat 


save "Figures/caucus_2018_vote_othercon.dta", replace


********************************************************************************
**Analysis of Observational Study of Precinct Meetings
********************************************************************************

use "Caucus Observer_Candidate Level with precinct_replication.dta", clear

**Create office categories
gen office_leader=0
replace office_leader=1 if office==1|office==6
gen office_consol=0
replace office_consol=1 if office==2|office==7
gen office_service=0
replace office_service=1 if office==3|office==4|office==5

**Create dummy for demand and supply conditions

gen demand=0
replace demand=1 if condition==3|condition==4

gen supply=0
replace supply=1 if condition==2|condition==4

**Create dummy for giving no speech
gen no_speech=1-speech


**Create dummies for topics mentioned
gen qual_mention=1-qual_noqual
gen ideo_mention=1-ideo_noment
gen plat_mention=1-plat_noment
gen gender_mention=1-gen_noment
gen lds_mention=1-lds_noment
gen issue_mention=1-iss_noiss
gen neigh_mention=1-neigh_noment
gen fam_mention=1-fam_noment

**Create dummies for competitive service races
gen compete_serv=0
replace compete_serv=1 if office==3 & runsec>1
replace compete_serv=1 if office==4 & runtr>1
replace compete_serv=1 if office==5 & runst>1

**Gendered appeals
gen womeny=0
replace womeny=1 if occu_home==1|iss_educ==1|fam_mention==1

gen meny=0
replace meny=1 if occu_busi==1|occu_armed==1|ideo_cons==1|iss_taxes==1|iss_spendef==1

label var office "Candidate Office"

label var qual_mention "Mentioned Qualifications"

label var issue_mention "Mentioned Issues"

label var ideo_mention "Mentioned Ideology"

label var neigh_mention "Mentioned Neighborhood"

label var plat_mention "Mentioned Party Platform"

label var fam_mention "Mentioned Family"

label var gender_mention "Mentioned Gender"

label var pol_prevoth "Mentioned previous political experience: other offices"

label var pol_prevsame "Mentioned previous political experience as state delegate"

label var occu_prof "Mentioned professional background"

label var occu_busi "Mentioned executive or business experience"

label var occu_armed "Mentioned military service"

label var pol_camp "Mentioned campaign experience"

label var occu_home "Mentioned being a homemaker or parent"

label var iss_educ "Mentioned education as issue"

label var iss_const "Mentioned the Constitution"

label var iss_marr "Mentioned marriage or marriage equality as issue"

label var iss_caucus "Mentioned the caucus system as issue"

label var iss_spendef "Mentioend government spending/the deficit as issue"

label var iss_taxes "Mentioned taxes as issue"

label var iss_gun "Mentioned gun control as issue"

label var iss_healthc "Mentioned health care as issue"

label var iss_econ "Mentioned the economy/jobs as issue"

label var iss_religf "Mentioned religious freedom as issue"

label var iss_envir "Mentioned the environment as issue"

label var womeny "Whether the candidate made stereotypically female appeals"

label var meny "Whether the candidate made steroetypically male appeals"

label var no_speech "Candidate did not make speech"

label var distance_100 "Distance in miles between precinct and site of state party convention/100"

label var prop_fem_attend2014 "Proportion of caucus attendees who are women"

label var sd2014 "Number of delegate positions available"

label var age2014 "Mean age of participants at precinct"

label var attendees2014 "Number of participants at precinct"



**Table 3: Gender Differences in Topics Mentioned, 2014 Neighborhood Caucus Observations
for var qual_mention issue_mention ideo_mention neigh_mention plat_mention fam_mention gender_mention: prtest X if office==6 & runsd>1, by(female)


**Table 4: What Sorts of Qualifications Are Mentioned?, 2014 Neighborhood Caucus Observations 
* Qualifications Mentioned 
for var pol_prevoth pol_prevsame occu_prof occu_busi occu_armed pol_camp occu_home: prtest X if speech==1 & qual_mention==1 & office==6 & runsd>1, by(female)

* Issues mentioned 
for var iss_educ iss_const iss_marr iss_caucus iss_spendef iss_taxes iss_gun iss_healthc iss_econ iss_religf iss_natld iss_envir: prtest X if speech==1 & issue_mention==1 & office==6 & runsd>1, by(female)


**Table A9: Electoral Success and Candidate Self-Presentation, Caucus Observation Study
probit winner i.womeny i.gender_mention qual_mention ideo_mention  i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==1 
outreg2 using Tables/Table_A9, replace dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit winner i.womeny i.meny i.gender_mention qual_mention i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==1
outreg2 using Tables/Table_A9, append dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit winner i.womeny i.gender_mention qual_mention ideo_mention  i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==0
outreg2 using Tables/Table_A9, append  dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 
probit winner i.womeny i.meny i.gender_mention qual_mention i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==0
outreg2 using Tables/Table_A9, append tex dec(3) addstat(Log Likelihood, e(ll), Pseudo R2, e(r2_p)) 



**Create figure for R

probit winner i.womeny i.gender_mention qual_mention ideo_mention  i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==1 
margins, dydx(womeny) saving(Figures/win_observe_fem, replace)
probit winner i.womeny i.gender_mention qual_mention ideo_mention  i.issue_mention no_speech sd2014 age2014 attendees2014 prop_fem_attend2014 distance_100 if office==6 & runsd>1 & female==0 
margins, dydx(womeny) saving(Figures/win_observe_male, replace)



use "Figures/win_observe_fem.dta", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin margin_eff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
*rename _m1 treat
rename _statistic statistic
gen cand_sex="Women"

save "Figures/win_observe_fem", replace

use "Figures/win_observe_male", clear
drop _deriv _term _predict _at _atopt _pvalue
rename _margin margin_eff
rename _se se
rename _ci_lb ci_lb
rename _ci_ub ci_ub
*rename _m1 treat
rename _statistic statistic
gen cand_sex="Men"

save "Figures/win_observe_male.dta", replace

append using "Figures/win_observe_fem.dta"


save "Figures/win_observe_marginfx.dta", replace


********************************************************************************
**Table A14: Demographic Characteristics of Republican Samples
**Comparing the caucus attender demographics with other relevant samples
**This table requires other publicly available datasets beyond those collected by the authors. 
**See authors for details and code.

